package xpn.business.fund_return.entity.rela_frcase;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Service
public class RelaFrCaseService {
    @Resource
    private RelaFrCaseDao relaFrCaseDao;

    public List<RelaFrCase> saveRelaFrCase(Long caseId, List<RelaFrCase> relaFrCaseList) {
        List<RelaFrCase> relaFrCaseListOld = relaFrCaseDao.findAllByCaseId(caseId);
        if(Objects.nonNull(relaFrCaseListOld) && relaFrCaseListOld.size()>0) {
            relaFrCaseDao.deleteAll(relaFrCaseListOld);
        }
        return relaFrCaseDao.saveAll(relaFrCaseList);
    }
}
